package com.xx.web.controller.system;

import com.xx.common.annotation.Log;
import com.xx.common.core.controller.BaseController;
import com.xx.common.core.domain.AjaxResult;
import com.xx.common.core.page.TableDataInfo;
import com.xx.common.enums.BusinessType;
import com.xx.common.utils.poi.ExcelUtil;
import com.xx.system.domain.SysNoticeLog;
import com.xx.system.service.ISysNoticeLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 通知公告-记录Controller
 *
 * @author anqi
 * @date 2024-08-24
 */
@Api(tags = "通知公告-记录")
@RestController
@RequestMapping("/system/systemlog")
public class SysNoticeLogController extends BaseController {

    @Autowired
    private ISysNoticeLogService sysNoticeLogService;

    /**
     * 查询通知公告-记录列表
     */
    @ApiOperation("查询通知公告-记录列表")
    @PreAuthorize("@ss.hasPermi('system:systemlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysNoticeLog sysNoticeLog) {
        startPage();
        List<SysNoticeLog> list = sysNoticeLogService.selectSysNoticeLogList(sysNoticeLog);
        return getDataTable(list);
    }

    /**
     * 导出通知公告-记录列表
     */
    @ApiOperation("导出通知公告-记录列表")
    @PreAuthorize("@ss.hasPermi('system:systemlog:export')")
    @Log(title = "通知公告-记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysNoticeLog sysNoticeLog) {
        List<SysNoticeLog> list = sysNoticeLogService.selectSysNoticeLogList(sysNoticeLog);
        ExcelUtil<SysNoticeLog> util = new ExcelUtil<SysNoticeLog>(SysNoticeLog.class);
        util.exportExcel(response, list, "通知公告-记录数据");
    }

    /**
     * 获取通知公告-记录详细信息
     */
    @ApiOperation("获取通知公告-记录详细信息")
    @PreAuthorize("@ss.hasPermi('system:systemlog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysNoticeLogService.selectSysNoticeLogById(id));
    }

    /**
     * 新增通知公告-记录
     */
    @ApiOperation("新增通知公告-记录")
    @PreAuthorize("@ss.hasPermi('system:systemlog:add')")
    @Log(title = "通知公告-记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysNoticeLog sysNoticeLog) {
        return toAjax(sysNoticeLogService.insertSysNoticeLog(sysNoticeLog));
    }

    /**
     * 修改通知公告-记录
     */
    @ApiOperation("修改通知公告-记录")
    @PreAuthorize("@ss.hasPermi('system:systemlog:edit')")
    @Log(title = "通知公告-记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysNoticeLog sysNoticeLog) {
        return toAjax(sysNoticeLogService.updateSysNoticeLog(sysNoticeLog));
    }

    /**
     * 删除通知公告-记录
     */
    @ApiOperation("删除通知公告-记录")
    @PreAuthorize("@ss.hasPermi('system:systemlog:remove')")
    @Log(title = "通知公告-记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysNoticeLogService.deleteSysNoticeLogByIds(ids));
    }

}
